var e = require;
var t = module;
var n = exports;
var o,
    i =
        (this && this.__extends) ||
        ((o = function (e, t) {
            return (o =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
                })(e, t);
        }),
        function (e, t) {
            var n;
            {
                function n() {
                    this.constructor = e;
                }
                o(e, t), (e.prototype = null === t ? Object.create(t) : ((n.prototype = t.prototype), new n()));
            }
        }),
    r =
        (this && this.__decorate) ||
        function (e, t, n, o) {
            var i,
                r = arguments.length,
                a = r < 3 ? t : null === o ? (o = Object.getOwnPropertyDescriptor(t, n)) : o;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) a = Reflect.decorate(e, t, n, o);
            else
                for (var s = e.length - 1; 0 <= s; s--)
                    (i = e[s]) && (a = (r < 3 ? i(a) : 3 < r ? i(t, n, a) : i(t, n)) || a);
            return 3 < r && a && Object.defineProperty(t, n, a), a;
        };
Object.defineProperty(n, "__esModule", {value: !0});
var a,
    s = e("player-war"),
    t = cc._decorator,
    e = t.ccclass,
    t = t.property,
    e =
        ((a = cc.Component),
        i(c, a),
        (c.prototype.start = function () {
            cc.game.on(cc.game.EVENT_HIDE, this.timePause, this),
                cc.game.on(cc.game.EVENT_SHOW, this.timeStart, this),
                (this.useTime = 0),
                (this.enabled = !1),
                this.updateName();
        }),
        (c.prototype.updateName = function () {
            var e = s.playerWar.getWarLevel(),
                e = s.playerWar.getArea(e);
            this.curName.string = e.name;
        }),
        (c.prototype.clear = function () {
            cc.game.off(cc.game.EVENT_HIDE, this.timePause, this),
                cc.game.off(cc.game.EVENT_SHOW, this.timeStart, this),
                (this.enabled = !1),
                (this.useTime = 0),
                this.updateTime();
        }),
        (c.prototype.timePause = function () {
            (this.enabled = !1), (this.isPause = !0);
        }),
        (c.prototype.timeStart = function () {
            (this.isPause = !1), (this.enabled = !0);
        }),
        (c.prototype.reset = function () {
            (this.curTime = 0), (this.useTime = 0), this.updateName(), this.updateTime();
        }),
        (c.prototype.saveTime = function () {
            var e;
            this.timePause(),
                s.playerWar.getIsGuideLevel() ||
                    ((e = s.playerWar.getWarLevel()), s.playerWar.setWarLevelTime(e, this.useTime));
        }),
        (c.prototype.updateTime = function () {
            var e = Math.floor(this.useTime / 60),
                t = Math.floor(this.useTime % 60);
            this.label.string = (e < 10 ? "0" + e : e) + ":" + (t < 10 ? "0" + t : t);
        }),
        (c.prototype.update = function (e) {
            this.isPause ||
                ((this.curTime += e), 1 <= this.curTime && ((this.curTime = 0), ++this.useTime, this.updateTime()));
        }),
        (c.prototype.getWarTimes = function () {
            return this.useTime;
        }),
        r([t(cc.Label)], c.prototype, "label", void 0),
        r([t(cc.Label)], c.prototype, "curName", void 0),
        r([e], c));
function c() {
    var e = (null !== a && a.apply(this, arguments)) || this;
    return (e.label = null), (e.curName = null), (e.curTime = 0), (e.useTime = 0), (e.isPause = !1), e;
}
n.default = e;
